package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.goods.pojo.Spec;
import com.itheima.service.SpecService;
import com.itheima.mapper.SpecMapper;
import entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;


/**
 *
 */
@Service
public class SpecServiceImpl extends ServiceImpl<SpecMapper, Spec>
    implements SpecService{
    @Autowired
    private SpecMapper specMapper;

    public Result findPage(Integer page1, Integer size){
        // 创建分页对象   泛型User表示对哪个实体进行分页
        IPage<Spec> page = new Page<>(page1,size);  //2 表示第几页 3表示每页显示几条数据
        specMapper.selectPage(page,null);   //分页查询语句  null表示嫁接其他其他条件进行分页

        // 获取分页数据信息
        List<Spec> specList = page.getRecords();
        if(specList==null){
            return Result.builder().flag(false).code(StatusCode.ERROR).message("搜索是失败").data(specList).build();

        }
        return Result.builder().flag(true).code(StatusCode.OK).data(specList).build();


    }



}




